{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">

                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('addCourse')}');">
                            <i class="fa fa-plus"></i> 添加课程介绍
                        </button>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.c_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>

                    <!--状态显示模板-->
                    <script type="text/html" id="statBar">
                        {{# if(d.c_status == 1){ }}
                        上架中
                        {{# } }}
                        {{# if(d.c_status == 2){ }}
                        已下架
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        {{# if(d.c_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.c_id}}','{:url('coursedown')}','确定下架吗?')" class="btn btn-primary btn-xs m-r-xs" title="下架">下架</a>
                        {{# } }}
                        {{# if(d.c_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.c_id}}','{:url('courseup')}','确定上架吗?')" class="btn btn-warning btn-xs m-r-xs" title="上架">上架</a>
                        {{# } }}
                        <!--编辑和详情-->
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('courseEdit')}?c_id={{d.c_id}}&type=1')" class="btn btn-primary btn-xs m-r-xs" title="详情">详情</a>
                        <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('courseEdit')}?c_id={{d.c_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑"><i class="fa fa-pencil">编辑</i></a>
                        <!---->
                        <a href="javascript:;" onclick="wk.confirm('{{d.c_id}}','{:url('coursedel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Ke/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',}
                  {type:'numbers', width: 60, title: '序号'}
                , {field: 'c_name', width: '', title: '标题', align: 'center'}
                , {field: 'c_thumb', width: 90, title: '缩略图', align: 'center', templet: '#imgTpl'}
                , {field: 'axe_name', width: 80, title: '乐器', align: 'center'}
                , {field: 'user_username', width: 80, title: '老师', align: 'center'}
                , {field: 'user_phone', width: 80, title: '老师电话', align: 'center'}
                , {field: 'panios', width: 130, title: '琴行', align: 'center'}
                , {field: 'c_num', width: '', title: '咨询人数', align: 'center'}
                , {field: 'c_status', width: '', title: '状态', align: 'center', toolbar: '#statBar'}
                , {field: 'c_time', width: '', title: '创建时间', align: 'center'}
                , {fixed: 'right', width: 250, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });

        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            wk.change(data.banner_id,"{:url('updateSort')}",field,value);
        });

        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['banner_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>